package com.example.other.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.example.authority.common.entity.Result;

@RestController
@Slf4j
public class SetmealController extends BaseController{

    @GetMapping("/setmeal/all")
    public Result getAllSetmeal(){
        try{
            return Result.succ(setmealService.list());
        }catch (Exception e){
            return Result.fail(e.getMessage());
        }
    }

    @GetMapping("/setmeal")
    public Result getSetmealBySex(@RequestParam Integer sex){
        try{
            return Result.succ(setmealService.getSetmealBySex(sex));
        }catch (Exception e){
            return Result.fail(e.getMessage());
        }
    }

    @GetMapping("/setmeal/id")
    public Result getSetmealById(Integer id) {
        try{
            return Result.succ(setmealService.getById(id));
        }catch (Exception e){
            return Result.fail(e.getMessage());
        }
    }
}
